// GxQuoteEventSink.cpp : implementation file
//

#include "stdafx.h"
#include "speedorder.h"
#include "GxQuoteEventSink.h"
#include "P2_i.c"
#include "CurPriceManager.h"
#include "SymbolManager.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// GxQuoteEventSink

IMPLEMENT_DYNCREATE(GxQuoteEventSink, CCmdTarget)

GxQuoteEventSink::GxQuoteEventSink()
{
	EnableAutomation();
	m_SymbolMgr = NULL;
}

GxQuoteEventSink::~GxQuoteEventSink()
{
}


void GxQuoteEventSink::OnFinalRelease()
{
	// When the last reference for an automation object is released
	// OnFinalRelease is called.  The base class will automatically
	// deletes the object.  Add additional cleanup required for your
	// object before calling the base class.
	m_Cookie = 0;
	CCmdTarget::OnFinalRelease();
}


BEGIN_MESSAGE_MAP(GxQuoteEventSink, CCmdTarget)
	//{{AFX_MSG_MAP(GxQuoteEventSink)
		// NOTE - the ClassWizard will add and remove mapping macros here.
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

BEGIN_DISPATCH_MAP(GxQuoteEventSink, CCmdTarget)
	//{{AFX_DISPATCH_MAP(GxQuoteEventSink)
	DISP_FUNCTION(GxQuoteEventSink, "OnQuoteChanged", OnQuoteChanged, VT_EMPTY, VTS_DISPATCH VTS_DISPATCH)
	//}}AFX_DISPATCH_MAP
END_DISPATCH_MAP()

// Note: we add support for IID_IGxQuoteEventSink to support typesafe binding
//  from VBA.  This IID must match the GUID that is attached to the 
//  dispinterface in the .ODL file.

// {B7C065E9-4D24-4AF6-8EFE-187D2DEBFF0C}

BEGIN_INTERFACE_MAP(GxQuoteEventSink, CCmdTarget)
	INTERFACE_PART(GxQuoteEventSink, DIID_IGxQuoteEvents, Dispatch)
END_INTERFACE_MAP()

/////////////////////////////////////////////////////////////////////////////
// GxQuoteEventSink message handlers

void GxQuoteEventSink::OnQuoteChanged(LPDISPATCH a_GxSymbol, LPDISPATCH a_GxQuote) 
{
	// TODO: Add your dispatch handler code here
	if (m_SymbolMgr == NULL) return;
	
	m_SymbolMgr->OnQuoteChanged();
}
